using System;
using System.Collections.Generic;
using System.Text;
using CodePlex.SpaceBlock.JobModel;
using System.Drawing;
using CodePlex.Resourceful;

namespace CodePlex.SpaceBlock.UI.Controls.Transfers
{
    public class JobInfoDisplay : NotifyObject
    {
        private Image _image;
        private string _caption;
        private string _description;
        private Guid _jobID;
        private JobStatus _status;

        private string _from;
        private string _to;
        private string _size;
        private string _transferred;

        private string _speed;

        private int _progress;

        public Image Image { get { return _image; } set { this.Set(value, "Image", ref _image); } }
        public string Caption { get { return _caption; } set { this.Set(value, "Caption", ref _caption); } }
        public string Description { get { return _description; } set { this.Set(value, "Description", ref _description); } }
        public Guid JobID { get { return _jobID; } set { this.Set(value, "JobID", ref _jobID); } }
        public JobStatus Status { get { return _status; } set  { 
            this.Set(value, "Status", ref _status);
            this.OnPropertyChanged("IsComplete");
            this.OnPropertyChanged("IsNotComplete");
        } }

        public string From { get { return _from; } set { this.Set(value, "From", ref _from); } }
        public string To { get { return _to; } set { this.Set(value, "To", ref _to); } }
        public string Size { get { return _size; } set { this.Set(value, "Size", ref _size); } }
        public string Transferred { get { return _transferred; } set { this.Set(value, "Transferred", ref _transferred); } }

        public string Speed { get { return _speed; } set { this.Set(value, "Speed", ref _speed); } }
        public int Progress { get { return _progress; } set { this.Set(value, "Progress", ref _progress); } }

        public JobInfoDisplay(Guid jobID)
        {
            _jobID = jobID;
        }

        public override int GetHashCode()
        {
            return this.JobID.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            JobInfoDisplay other = obj as JobInfoDisplay;
            return other != null && this.JobID.Equals(other.JobID);
        }



        public bool IsComplete
        {
            get
            {
                return this.Status == JobStatus.Completed;
            }
        }
        public bool IsNotComplete
        {
            get
            {
                return !this.IsComplete;
            }
        }



        public static bool IsRunning(JobInfoDisplay item)
        {
            return item.Status == JobStatus.Running;
        }
        public static bool IsFinished(JobInfoDisplay item)
        {
            return Utils.In(item.Status,
                JobStatus.Completed,
                JobStatus.Failed,
                JobStatus.Cancelled
            );
        }
    }

}
